#include <fstream>
#include <string>
#include <math.h>
#include <iostream>
#include "Material.h"

using namespace std;
  
Material::Material(){
  Material_Ambient[0] = 0.1;
  Material_Ambient[1] = 0.1;
  Material_Ambient[2] = 0.1;
  Material_Ambient[3] = 1.0;

  Material_Diffuse[0] = 0.1;
  Material_Diffuse[1] = 0.1;
  Material_Diffuse[2] = 0.1;
  Material_Diffuse[3] = 1.0;

  Material_Specular[0] = 0.1;
  Material_Specular[1] = 0.1;
  Material_Specular[2] = 0.1;
  Material_Specular[3] = 1.0;

  shine = 50;
}

void Material::set_Material_Ambient(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
  Material_Ambient[0] = a;
  Material_Ambient[1] = b;
  Material_Ambient[2] = c;
  Material_Ambient[3] = d;
}
void Material::set_Material_Diffuse(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
 
  Material_Diffuse[0] = a;
  Material_Diffuse[1] = b;
  Material_Diffuse[2] = c;
  Material_Diffuse[3] = d;
}
void Material::set_Material_Specular(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
  Material_Specular[0] = a;
  Material_Specular[1] = b;
  Material_Specular[2] = c;
  Material_Specular[3] = d;
}
void Material::set_Shininess(int shin){
  shine = shin;
}
   
void Material::get_All_Mat(){
  int i=0;
  cout<<"Material_Ambient :"<<endl;
  for(i=0;i<4;i++)cout<<Material_Ambient[i]<<endl;
  cout<<"Material_Diffuse :"<<endl;
  for(i=0;i<4;i++)cout<<Material_Diffuse[i]<<endl;
  cout<<"Material_Specular :"<<endl;
  for(i=0;i<4;i++)cout<<Material_Specular[i]<<endl;
  cout<<"Shininess :"<<shine<<endl;
}

  
void Material::ActiveMat (){
    glEnable(GL_COLOR_MATERIAL);

    glMaterialfv( GL_FRONT, GL_AMBIENT, Material_Ambient);
    glMaterialfv( GL_FRONT, GL_DIFFUSE, Material_Diffuse);
    glMaterialfv( GL_FRONT, GL_SPECULAR, Material_Specular);
    glMaterialf( GL_FRONT, GL_SHININESS, shine);
  }

void Material::DisactiveMat(){ 
    glDisable(GL_COLOR_MATERIAL);
}
